<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加商户</title>
    <style>
        .wu-pos-a {
            box-sizing: border-box;
            padding-top: 39px;
            width: 20%;
            left: auto;
            right: 0;
        }
        .wu-inline>.form-group{
             margin-right:0;
             margin-left:0;
        }
    </style>
</head>
<body>

<div class="pos-r">
    <nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
        <span class="c-gray en">&gt;</span>
        信息管理
        <span class="c-gray en">&gt;</span>
        商户管理
        <span class="c-gray en">&gt;</span>
        添加商户
    </nav>

    <div>
        <div class="page-container">
            <form action="" method="post" class="form form-horizontal" id="bizManage-form-member-add">
                <input style="display: none;" id="bizManage_addArray" name="array"/>
                <div class="form-unit">基本信息</div>
                <div class="form-group">
                    <label class="control-label col-xs-4 col-sm-3"><span class="c-red"></span>商户名称：</label>
                    <div class="formControls col-xs-4 col-sm-4">
                        <input type="text" class="form-control" value="" placeholder="必填项" id="bizManage-add-subMchName" name="subMchName">
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-4 col-sm-3"><span class="c-red"></span>商户编号：</label>
                    <div class="formControls col-xs-4 col-sm-4">
                        <input type="text" class="form-control" value="" placeholder="必填项" id="bizManage-add-subMchId" name="subMchId">
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                        <input onclick="bizManageAddFun.submitAction();return false;" class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;"/>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

<script type="text/javascript">
    //点位管理，添加服务
    var bizManageAddFun;

    bizManageAddFun = {
        init: function () {
            let _this = this;

            _this.bootstrapvalidatorForm();
        },
        //表单提交
        submitAction: function () {
            //bootstrap验证
            var bootstrapValidator = $("#bizManage-form-member-add").data('bootstrapValidator');
            bootstrapValidator.validate();
            if(bootstrapValidator.isValid())
                $("#bizManage-form-member-add").submit();
            else return;

            //提交
            $.ajax({
                type: "GET",
                url: "biz/insertShopMch",
                data: $("#bizManage-form-member-add").serialize(),
                dataType: "json",
                success: function (data) {
                    if (data.state) {
                        //关闭新增窗口
                        removeIframe();
                        bizManageFun.searchAction();
                    }
                },
                error: function () {
                    alert("error");
                }
            });
        },
        bootstrapvalidatorForm: function () {
            $('#bizManage-form-member-add').bootstrapValidator({
                message: 'This value is not valid',
                excluded : [':disabled'],
                feedbackIcons: {
                    valid: 'glyphicon glyphicon-ok',
                    invalid: 'glyphicon glyphicon-remove',
                    validating: 'glyphicon glyphicon-refresh'
                },
                fields: {
                    subMchName: {
                        validators: {
                            notEmpty: {
                                message: '商户名称不能为空'
                            },
                            stringLength: {
                                min: 2,
                                max: 100,
                                message: '商户名称长度必须在2到100位之间'
                            }
                        }
                    },
                    subMchId: {
                        validators: {
                            notEmpty: {
                                message: '商户编号不能为空'
                            },
                            stringLength: {
                                min: 10,
                                max: 10,
                                message: '商户编号长度必须为10位'
                            }
                        }
                    }
                }
            });
        }
    };

    bizManageAddFun.init();
</script>
</body>
</html>